package com.wo56.pushmsgcenter.common.converter;

import java.util.Date;

import org.apache.commons.beanutils.converters.AbstractConverter;

import com.framework.core.util.DateUtil;

public class StringConverter extends AbstractConverter{

    public StringConverter() {
        super();
    }
    
    public StringConverter(Object defaultValue) {
        super(defaultValue);
    }
    
	@Override
	protected Object convertToType(Class type, Object value) throws Throwable {
		return value.toString();
	}
	
    protected String convertToString(Object value) throws Throwable {
		if(value instanceof Date){
			return DateUtil.formatDate((Date) value,"yyyyMMddHHmmss");
		}
		return value.toString();
    }
    
	@Override
	protected Class getDefaultType() {
		return String.class;
	}

}
